package com.gitee.magic.core.utils;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.Date;



/**
 * @author start
 */
public class ContextSupportType {
	
	public static boolean isSupportTypeCheckByByte(Class<?> type){
		if(type==byte.class||type.equals(Byte.class)){
			return true;
		}
		return false;
	}
	
	public static boolean isSupportTypeCheckByChar(Class<?> type){
		if(type==char.class||type.equals(Character.class)){
			return true;
		}
		return false;
	}
	
	public static boolean isSupportTypeCheckByBoolean(Class<?> type){
		if(type==boolean.class||type.equals(Boolean.class)){
			return true;
		}
		return false;
	}
	
	public static boolean isSupportTypeCheckByShort(Class<?> type){
		if(type==short.class||type.equals(Short.class)){
			return true;
		}
		return false;
	}
	
	public static boolean isSupportTypeCheckByInteger(Class<?> type){
		if(type==int.class||type.equals(Integer.class)){
			return true;
		}
		return false;
	}
	
	public static boolean isSupportTypeCheckByLong(Class<?> type){
		if(type==long.class||type.equals(Long.class)){
			return true;
		}
		return false;
	}
	
	public static boolean isSupportTypeCheckByFloat(Class<?> type){
		if(type==float.class||type.equals(Float.class)){
			return true;
		}
		return false;
	}
	
	public static boolean isSupportTypeCheckByDouble(Class<?> type){
		if(type==double.class||type.equals(Double.class)){
			return true;
		}
		return false;
	}
	
	public static boolean isSupportTypeCheckByBigInteger(Class<?> type){
		return type.equals(BigInteger.class);
	}
	
	public static boolean isSupportTypeCheckByBigDecimal(Class<?> type){
		return type.equals(BigDecimal.class);
	}
	
	/**
	 * 日期型
	 * @param type
	 * @return
	 */
	public static boolean isSupportTypeCheckByDate(Class<?> type){
		if(type.equals(Date.class)){
			return true;
		}
		return false;
	}
	
	/**
	 * 字符串型
	 * @param type
	 * @return
	 */
	public static boolean isSupportTypeCheckByString(Class<?> type){
		if(type.equals(String.class)||
				type.equals(StringBuilder.class)||
				type.equals(StringBuffer.class)){
			return true;
		}
		return false;
	}
	
	/**
	 * 主键支持的类型注解{link @Id}
	 * @param type
	 * @return
	 */
	public static boolean isSupportTypeCheckByPrimaryKey(Class<?> type){
		if(isSupportTypeCheckByInteger(type)){
			return true;
		}
		if(isSupportTypeCheckByLong(type)){
			return true;
		}
		if(isSupportTypeCheckByBigInteger(type)){
			return true;
		}
		if(isSupportTypeCheckByString(type)){
			return true;
		}
		return false;
	}
	
	/**
	 * 支持的数字型
	 * @param type
	 * @return
	 */
	public static boolean isSupportTypeCheckByNumber(Class<?> type){
		if(isSupportTypeCheckByShort(type)){
			return true;
		}
		if(isSupportTypeCheckByInteger(type)){
			return true;
		}
		if(isSupportTypeCheckByLong(type)){
			return true;
		}
		if(isSupportTypeCheckByFloat(type)){
			return true;
		}
		if(isSupportTypeCheckByDouble(type)){
			return true;
		}
		if(isSupportTypeCheckByBigInteger(type)){
			return true;
		}
		if(isSupportTypeCheckByBigDecimal(type)){
			return true;
		}
		return false;
	}
	
}
